﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using NS.Utilities;
using BLL;

public partial class Platform_UserAllot : System.Web.UI.Page
{
    private string orderID;
    protected void Page_Load(object sender, EventArgs e)
    {
        orderID = Request.QueryString["ID"];
        if (!IsPostBack)
        {
            labUser.Text = OrderService.GetUserName(orderID);
            GridViewBind();
        }
    }
    protected void GridViewBind()
    {
        FGridView1.DataSource = OrderService.GetUserAllot();
        FGridView1.DataBind();
    }
    protected void btnAllot_Click(object sender, EventArgs e)
    {
        string userID = ((Button)sender).CommandArgument.ToString();
        int state = OrderService.GetOrderState(orderID);
        if (state == 1 || state == 4)
        {
            if (OrderService.OrderAllot(orderID, userID))
            {
                MessageBox.AppendScript(this, "alert('派单成功！');$(':input[id$=\"btnSearch\"]', window.parent.document.body).click();");
            }
            else
            {
                MessageBox.ShowError(this, "操作失败！");
            }
        }
        else
        {
            MessageBox.ShowError(this, "订单状态发生变化！");
        }
        GridViewBind();
    }
}